<?php

include_once XOOPS_ROOT_PATH.'/class/xoopsformloader.php';

#XoopsFormSelect($caption, $name, $value=null, $size=1, $multiple=false)
#addOption($value, $name="")
#addOptionArray($options)
#XoopsFormTextArea($caption, $name, $value="", $rows=5, $cols=50)
#XoopsFormButton($caption, $name, $value="", $type="button")
if (!is_object($itemO)) echo "no class found";

$form = new XoopsThemeForm(_MD_EDITOBJECT, 'newobjform', 'index.php?op=edit_ok');
#$form->addElement($obj_type_el = new XoopsFormSelect(_MD_OBJECT_NAME, "obj_type"));						
#$obj_type_el->addOptionArray($typeH->getObjects(null,2));
$form->addElement($obj_name_el = new XoopsFormText(_MD_OBJECT_TITLE, 'obj_title', 50, 255,$itemO->getVar('title')));

$form->addElement($obj_city_el = new XoopsFormSelect(_MD_OBJECT_CITY, "obj_city_id",$itemO->getVar('city_id')));						


$criteria = new CriteriaCompo;
$criteria->setSort('title');
$countriesarr = $countryH->getObjects($criteria,1);

foreach ($countriesarr as $countryO){
$criteria = new CriteriaCompo(new Criteria('countryid',$countryO->getVar('id')));
$criteria->setSort('title');
$citiesarr = $cityH->getObjects($criteria,1);
    foreach ($citiesarr as $cityO){
     unset($countryO,$regionH);
     $countryO = $countryH->get($cityO->getVar('countryid'));
    $obj_city_el->addOption($cityO->getVar('id'),$countryO->getVar('title').'>>'.$cityO->getVar('title'));
    } 
}


$citiesarr = $cityH->getObjects($criteria,1);


$form->addElement($obj_address_el = new XoopsFormText(_MD_OBJECT_ADDRESS, 'obj_address', 50, 255,$itemO->getVar('address')));
$form->addElement($obj_phone_el = new XoopsFormText(_MD_OBJECT_PHONE, 'obj_phone', 50, 255,$itemO->getVar('phone')));
$form->addElement($obj_url_el = new XoopsFormText(_MD_OBJECT_URL, 'obj_url', 50, 255,$itemO->getVar('url')));
$form->addElement($obj_email_el = new XoopsFormText(_MD_OBJECT_EMAIL, 'obj_email', 50, 255,$itemO->getVar('email')));
$form->addElement($obj_description_el = new XoopsFormTextArea(_MD_OBJECT_DESCRIPTION, 'obj_description', $itemO->getVar('description'), $rows=5, $cols=50));
$form->addElement(new XoopsFormButton('', 'createbtn', _EDIT,'submit'));
echo $form->render();



?>
